/**
 *  @file  vsTimer.h version 1.0 2007-11-20 
 *  @brief Definition of class Timer.
 *  Copyright (c) 2007 by @author <abitfree@gmail.com>
 */

#ifndef __VS_TIMER_H__
#define __VS_TIMER_H__

#include <cstdio>
#include <cstdlib>
#include <ctime>

namespace vs
{

/// A timer class at millisecond.
class Timer
{
public:
	/// Constructor, record the start time.
	Timer()
	{
		Restart();
	}

	/// Reset the start time.
	void Restart()
	{
		start_ = std::clock();
	}

	/// Get the elapsed time by millisecond.
	double Elapsed() const
	{
		return (double)(std::clock() - start_) / CLOCKS_PER_SEC;
	}

private:
	// The timer's start time.
	std::clock_t start_;
};

}

#endif // __VS_TIMER_H__
